package com.huilian.iotbox.admin.quartz.job;

import com.huilian.iotbox.admin.service.SettleResultService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import javax.annotation.Resource;
import com.huilian.iotbox.data.utils.DateTimeUtils;

import java.time.LocalDate;

/**
 * @author LinYinDong
 * @date 2024/8/26 下午4:03
 */
@Slf4j
public class SettleResultJob implements BaseJob {
    @Resource
    private SettleResultService settleResultService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("--------------定时任务 统计结算查询2开始 时间{}---------------", DateTimeUtils.currTime());
        // 当天，yyyyMMdd
        final String today = DateTimeUtils.convert(LocalDate.now(), DateTimeUtils.LONG_DATE_FORMATTER);
        // 昨天，yyyyMMdd
        final String yesterday = DateTimeUtils.convert(LocalDate.now().minusDays(1), DateTimeUtils.LONG_DATE_FORMATTER);
        // 昨天，yyyy-MM-dd
        final String dateStr = DateTimeUtils.getYesterday();
        // 昨天开始时间
        String yesterdayStartTime = DateTimeUtils.getYesterdayStartTime();
        // 昨天结束时间
        String yesterdayEndTime = DateTimeUtils.getYesterdayEndTime();

        settleResultService.mchDayCloseQuery(today, yesterday, dateStr, yesterdayStartTime, yesterdayEndTime);
        log.info("--------------定时任务 统计结算查询2结束 end时间{}---------------", DateTimeUtils.currTime());
    }
}
